﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BenefitHelper.Config
{
    /// <summary>
    /// 用户权限设定
    /// </summary>
    public class UserPrower
    {
        /// <summary>
        /// 判断用户是否具有某项权限
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public bool UserHasPrower(int userid, string prowerName, DB.DBManager db)
        {
            bool hasPower = false;
            //var query = db.UserPrower.Where(a => a.ProwerName.Equals(prowerName)).Where(a => a.UserId == userid).ToList();
            //if (query.Count() > 0)//用户已经对某权限进行了设定
            //{
            //    hasPower = query.First().IsAllow;
            //}
            //else//用户未对某权限进行设定，采用全局默认设定
            //{
            //    hasPower = new GlobalPrower().HasPrower(prowerName, db);
            //}
            return hasPower;
        }
        /// <summary>
        /// 判断操作员是否具有某项权限
        /// </summary>
        /// <param name="operatorid"></param>
        /// <returns></returns>
        public bool OperatorHasPrower(int operatorid, string prowerName, DB.DBManager db)
        {
            bool hasPower = false;
            //var query = db.UserPrower.Where(a => a.ProwerName.Equals(prowerName)).Where(a => a.OperatorId == operatorid).ToList();
            //if (query.Count() > 0)//用户已经对某权限进行了设定
            //{
            //    hasPower = query.First().IsAllow;
            //}
            //else//用户未对某权限进行设定，采用全局默认设定
            //{
            //    hasPower = new GlobalPrower().HasPrower(prowerName, db);
            //}
            return hasPower;
        }
    }
}